{*
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 *}
{script src='js/attachment.js'}
{script_def}
<!--
var agora_preview_url = '{url task=post page=reply action=preview id=$topic_id format=raw}';
{literal}
function agora_preview() {
	var preview_data = {req_message: ($$('textarea[name=req_message]').getValue()).toString()};
	new Ajax(agora_preview_url, {
			method: 'post',
			data: preview_data,
			onFailure: function(){},
			onComplete: function(inResponse) {
				var box = SqueezeBox.initialize();
				box.assignOptions();
				box.setContent('string',inResponse);
			}
	}).request();
}
function populate_hidden() {
	if($('upload').value) {
		var req = ($$('textarea[name=req_message]').getValue()).toString();
		document.getElementById('msg_hidden').value = escape(req);
		document.uploadform.submit();
	} else {
		alert('Please choose a file');
	}
}
{/literal}
//-->
{/script_def}

<div class="ag_rightend">
	<h2 class="ag_headerbar"><span class="ag_middle">##Quick post##</span></h2>
</div>
<div class="ag_outerwrap">
	<form id="post" method="post" name="post" action="{url task=post page=reply id=$topic_id}">
		{if $agora_user.id eq '0'}
		<fieldset class="ag_inform">
			<legend class="ag_color">##User information##</legend>
			<label>
				##Name##
				<input name="topic_username" class="required" type="text" value="{if $topic_username}{$topic_username|escape}{/if}" />
			</label>
			<label>
				##Email##
				<input name="guest_email" class="email required" type="text" value="{if $topic_email}{$topic_email|escape}{/if}" />
			</label>
		</fieldset>
		{/if}
		<fieldset>
			<legend class="ag_color">##Write message legend##</legend>
			{include file=agora:post/quick_post.tpl}
		</fieldset>
		<fieldset class="ag_inform">
			<legend class="ag_color">##Options##</legend>
			<div class="ag_infldset">
				<label>
					<input name="subscribe" type="checkbox" value="1" {if $agora_config.o_auto_subscriptions and $agora_user.auto_subscriptions}checked="checked"{/if} />
					##Subscribe##
				</label>
			</div>
		</fieldset>
		<div class="ag_postbuttons">
			<span>
				<input class="ag_button ag_btn_submit" type="submit" name="submit" value="##Submit##" title="##Submit##" accesskey="s" tabindex="5" />
				<input class="ag_button ag_btn_preview" type="button" name="preview" value="##Preview##" title="##Preview##" accesskey="p" onclick="agora_preview()" tabindex="4" />
			</span>
		</div>
	</form>
	{if $agora_config.o_allow_attach eq '1' and $agora_config.o_attach_type eq '0' and $agora_user.id}
	<form id="uploadform" name="uploadform" method="post" action="{url task=upload action=add redir=self}" onsubmit="populate_hidden();return false;" enctype="multipart/form-data">	
		<fieldset class="ag_inform">
			<legend class="ag_color">##Attachment##</legend>
			<div class="ag_infldset">
				<input type="file" id="upload" name="upload" style="width:99%;" />
				<input class="ag_button ag_btn_submit" type="submit" name="sbm" value="##Upload##" title="##Upload##" />
				<input type="hidden" name="msg_hidden" id="msg_hidden" value="" />
			</div>
		</fieldset>
	</form>
	{/if}
	<script type="text/javascript">
	<!--
	{literal}
	window.addEvent('domready', function(){
		var myFormValidation = new Validate('post',{
			errorClass: 'red',
			label: '##Please wait##'
		});
	});
	{/literal}
	//-->
	</script>
	<script type="text/javascript">
	<!--
	{if isset($smarty.session.form_hidden)}
		document.getElementById('req_message').innerHTML = unescape('{$smarty.session.form_hidden.message}');
		{php} unset($_SESSION['form_hidden']); {/php}
	{/if}
	{if isset($smarty.session.add_attachment)}
		image('{$smarty.session.add_attachment.path}','{$smarty.session.add_attachment.name}','{$smarty.session.add_attachment.mini}','{$smarty.session.add_attachment.width}','{$smarty.session.add_attachment.height}');
		{php} unset($_SESSION['add_attachment']); {/php}
	{/if}
	//-->
	</script>
</div>